//
//  ViewController.swift
//  SSCommentUI
//
//  Created by 松松 on 05/16/2019.
//  Copyright (c) 2019 松松. All rights reserved.
//

import UIKit
import Foundation
import SSExtensions
import SSCommentUI
import SSComment



class ViewController: UIViewController {

    let commentVM = SSCommentViewModel()

    override func viewDidLoad() {
        super.viewDidLoad()

        let button = UIButton(frame: CGRect(x: 100, y: 100, width: 100, height: 100))
        button.backgroundColor = UIColor.red
        button.setTitle("你好", for: .normal)
        button.setTitleColor(UIColor.lightText, for: .normal)
        view.addSubview(button)

        button.addTarget(self, action: #selector(buttonClick(_:)), for: .touchUpInside)
        
    }

    @objc func buttonClick(_ sender: UIButton){

        let vc = CommentTextFieldViewController.init(placeholder: "字符串", placeholderColor: UIColor.lightText, maxLength: 150) { (text) in

        }
        self.present(vc, animated: true, completion: nil)

//        let vc = SSCommentViewController()
//
//                let userModel = CommentUserModel()
//                userModel.appCode = "1001013"
//                userModel.fromUserId = ""
//                userModel.fromUserHead = nil
//                userModel.fromUserName = "名字"
//                userModel.mainTypeCode = "1"
//
//                SSCommentUI.setUserModel(userModel)
//                self.present(vc, animated: true, completion: nil)


    }

}


extension UILabel{

    fileprivate struct AssociatedKeys{
        static var isDefault : Bool = true
        static var fontSize : CGFloat = 16
    }

    @IBInspectable open var isDefault : Bool{
        get{
            let isDefault = objc_getAssociatedObject(self, &AssociatedKeys.isDefault) as? Bool
            return isDefault ?? true
        }
        set{

            objc_setAssociatedObject(self, &AssociatedKeys.isDefault, newValue, .OBJC_ASSOCIATION_ASSIGN)

        }
    }

    @IBInspectable open var fontSize : CGFloat{
        get{
            let size = objc_getAssociatedObject(self, &AssociatedKeys.fontSize) as? CGFloat
            return size ?? 16
        }
        set{

            objc_setAssociatedObject(self, &AssociatedKeys.fontSize, newValue, .OBJC_ASSOCIATION_ASSIGN)

        }
    }

    override open func awakeFromNib() {
        super.awakeFromNib()
        font = UIFont.systemFont(ofSize: fontSize)
    }

}
